def validate_id(id_str):
    if len(id_str)>8:
        return False
    allowed=set("adcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
    return all(c in allowed for c in id_str)
def validate_email(email):
    if '@' not in email or email.count('@') != 1:
        return False
    _, domain = email.split('@')
    return '.' in domain
def validate_id_num(id_num):
    if len(id_num) not in(15,18):
        return False
    if len(id_num)==14:
        return id_num.isdigit()
    else:
        return id_num[:17].isdigit()and(id_num[-1].isdigit()or id_num[-1].upper()=='X')
def validate_name(name):
    if len(name)<1 or len(name)>4:
        return False
    return all('\u9fff' for c in name)
def get_gender(id_num):
    gender_bit=id_num[-1] if len(id_num)==15 else id_num[-2]
    return '男' if int(gender_bit)% 2==1 else '女'
while True:
    user_id=input("请输入ID：")
    if validate_id(user_id):
        break
    print("ID格式错误！")
while True:
    email=input("请输入EMATL地址：")
    if validate_email(email):
        break
    print("EMAIL格式错误!")

while True:
    id_num=input("请输入身份证号码：")
    if validate_id_num(id_num):
        break
    print("身份证号码格式错误！")

while True:
    name=input("请输入姓名：")
    if validate_name(name):
        break
    print("姓名格式错误！")

gender=get_gender(id_num)
print("\n注册成功！用户信息如下：")
print(f"ID:{user_id}")
print(f"EMAIL:{email}")
print(f"身份证号码：{id_num}")
print(f"姓名：{name}")
print(f"性别：{gender}")